package com.shijunhao.graduation.service.system.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.shijunhao.graduation.domain.entity.SystemDictItem;
import com.shijunhao.graduation.mapper.SystemDictItemMapper;
import com.shijunhao.graduation.service.system.ISystemDictItemService;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author shijunhao
 * @since 2022-03-04
 */
@Service
public class SystemDictItemServiceImpl extends BaseServiceImpl<SystemDictItemMapper, SystemDictItem> implements ISystemDictItemService {


    @Override
    public List<SystemDictItem> loadByDictId(Long dictId) {
        return selectByCondition(Wrappers.lambdaQuery(SystemDictItem.class).eq(SystemDictItem::getDictId,dictId));
    }

    @Override
    public SystemDictItem loadByDictIdValue(Long dictId, Integer value) {
        return getOne(Wrappers.lambdaQuery(SystemDictItem.class).eq(SystemDictItem::getDictId,dictId).eq(SystemDictItem::getDictValue,value));
    }

    @Override
    public SystemDictItem loadByDictIdLabel(Long dictId, String label) {
        return getOne(Wrappers.lambdaQuery(SystemDictItem.class).eq(SystemDictItem::getDictId,dictId).eq(SystemDictItem::getDictLabel,label));
    }

    @Override
    public boolean deleteByDictId(Long dictId) {
        return deleteByCondition(Wrappers.lambdaUpdate(SystemDictItem.class).eq(SystemDictItem::getDictId, dictId));
    }

    @Override
    public boolean deleteByDictIds(Collection<Long> dictIds) {
        return deleteByCondition(Wrappers.lambdaUpdate(SystemDictItem.class).in(SystemDictItem::getDictId, dictIds));
    }
}
